﻿using AppService.IService.Basic_information;
using Domain.Entity.Basic_information;
using Domain.Entity.System_setting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WebAPI.Controllers.Basic_information
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DriversController : ControllerBase
    {

        public IDriversService drivers { get; set; }

        /// <summary>
        /// 查询司机信息
        /// </summary>
        /// <param name="currentPage">当前页</param>
        /// <param name="pageSize">条数</param>
        /// <param name="date1">初始时间</param>
        /// <param name="date2">结束时间</param>
        /// <param name="value2">姓名</param>
        /// <returns></returns>
        [HttpGet]
        public List<Drivers_ment> GetDrivers(int currentPage, int pageSize, string? date1, string? date2, string? value2)
        {
            return drivers.GetDrivers(currentPage, pageSize, date1, date2, value2);
        }

        /// <summary>
        /// 获取总页数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetCount(string? date1, string? date2, string? value2)
        {
            return drivers.GetCount(date1, date2, value2);
        }

        /// <summary>
        /// 添加司机信息
        /// </summary>
        /// <param name="driver">司机类</param>
        /// <returns></returns>
        [HttpPost]
        public bool AddDrivers([FromBody]Drivers_ment driver)
        {
            return drivers.AddDrivers(driver);
        }

        /// <summary>
        /// 根据id查询司机信息
        /// </summary>
        /// <param name="id">司机id</param>
        /// <returns></returns>
        [HttpGet]
        public Drivers_ment GetDriver(int id)
        {
            return drivers.GetDriver(id);
        }

        /// <summary>
        /// 修改司机信息
        /// </summary>
        /// <param name="driver">司机类</param>
        /// <returns></returns>
        [HttpPut]
        public bool UpdDrivers(Drivers_ment driver)
        {
            return drivers.UpdDrivers(driver);
        }

        /// <summary>
        /// 删除司机信息
        /// </summary>
        /// <param name="id">司机id</param>
        /// <returns></returns>
        [HttpDelete]
        public bool DelDriver(int id)
        {
            return drivers.DelDriver(id);
        }

        /// <summary>
        /// 根据编号查询司机
        /// </summary>
        /// <param name="id">司机id</param>
        /// <returns></returns>
        [HttpGet]
        public Drivers_ment GetById(int id)
        {
            return drivers.GetDriverById(id);
        }

    }
}
